package com.pingan.controller;

import java.util.Calendar;
import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.pingan.stat.reposys.pahaoche.service.PAHaoCheStatService;

@Controller
public class PAHaoCheStatController {

	@Resource
	private PAHaoCheStatService pAHaoCheStatService;

	@RequestMapping("/pahaochestat")
	public void getValue(final String date, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		Date d = null;
		if (StringUtils.isBlank(date) || StringUtils.isEmpty(date)) {
			Calendar cal = Calendar.getInstance();
			cal.add(Calendar.DAY_OF_YEAR, -1);
			d = cal.getTime();
		} else {
			d = DateUtils.parseDate(date, new String[] { "yyyyMMdd" });
		}

		pAHaoCheStatService.dailyStat(d);

	}

}
